using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace MicroStar.Samples
{
    public class Game1 : Game
    {
        private GraphicsDeviceManager graphics;
        private SpriteBatch spriteBatch;
        private ParticleEffect effect;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            effect = ParticleEffectFactory.Initialize(10000, 2000)
                .SetMaxParticleSpeed(2f)
                .SetEmitAmount(75)
                .AddTexture(Content.Load<Texture2D>(@"Textures\particle"))
                .AddModifier(new AlphaAgeTransform())
                .Create();
        }

        protected override void Update(GameTime gameTime)
        {
            Vector2 emitPosition = new Vector2(GraphicsDevice.Viewport.Width / 2f, GraphicsDevice.Viewport.Height / 2f);
            effect.Emit(gameTime, emitPosition);

            effect.Update(gameTime);

            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin();
            effect.Draw(spriteBatch);
            spriteBatch.End();

            base.Draw(gameTime);
        }
    }
}
